<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>sign-up</title>
    <link rel="stylesheet" href="../css/common_form.css">
    <script src="../js/axios.min.js"></script>
    <script src="../js/API.js"></script>
</head>
<body>
    <header>
        <div class="header-line"></div>
    </header>
    <div class="content">
        <img class="content-logo" src="../img/下载JD狗 (1).png" alt="logo">
        <h1 class="content-title">创建账户</h1>
        <div class="content-form">
            <form method="post" action="" onsubmit="return submitTest()">
                <div id="change_margin_1">
                    <input class="user" type="text" name="user" placeholder="请输入用户名" onblur="oBlur_1()" onfocus="oFocus_1()">
                </div>
                <!-- input的value为空时弹出提醒 -->
                <p id="remind_1"></p>
                <div id="change_margin_2">
                    <input class="password" type="password" name="password" placeholder="请输入密码" onblur="oBlur_2()" onfocus="oFocus_2()">
                </div>
                <!-- input的value为空时弹出提醒 -->
                <p id="remind_2"></p>
                <div id="change_margin_3">
                    <input class="content-form-signup" type="submit" value="创建账户">
                </div>
            </form>
        </div>
        <div class="content-login-description">已经拥有账户？</div>
        <div><a class="content-login-link" href="log_in.html">登录</a></div>
    </div>
<script src="../js/common_form_test.js"></script>
<script>
     /* 
            点击按钮 
            获取用户名和密码
            发起请求
        
        */
        let ipts = document.querySelectorAll('input');

        ipts[2].onclick = function () {

            var username = ipts[0].value;
            var password = ipts[1].value;

            let params = {
                username: username,
                password
            }

            console.log(params);

            axios.get(regAPI, {
                params: params
            }).then(res => {
                console.log(res.data);
                alert(res.data.msg)
                if (res.data.code == 1) {
                    location.href = 'login.html'
                }
            })
        }
</script>
</body>
</html>